#ifndef HEADGENASTCONSUMER_H
#define HEADGENASTCONSUMER_H

#include <clang/AST/ASTConsumer.h>
#include <clang/AST/PrettyPrinter.h>

#include <LinkedIdentifierInfo.h>

namespace clang {
	class SourceManager;
	class FunctionDecl;
	class VarDecl;
}

namespace llvm {
	class raw_ostream;
}

class HeadgenAstConsumer : public clang::ASTConsumer
{
public:
	HeadgenAstConsumer(clang::SourceManager &sm,
					   LinkedIdentifierInfoMap &idMap,
					   LinkedIdentifierInfoList &idList);
	~HeadgenAstConsumer();

	void flush();

private:
	virtual void HandleTopLevelDecl(clang::DeclGroupRef D);

	void processFunctionDecl(clang::FunctionDecl *D);
	void processRecordDecl(clang::RecordDecl *D);
	void processTypedefDecl(clang::TypedefDecl *D);
	void processVarDecl(clang::VarDecl *D);

	void getTypeDeps(clang::QualType T, std::list<std::string> &res);

private:
	clang::SourceManager &m_sourceManager;
	LinkedIdentifierInfoMap &m_idMap;
	LinkedIdentifierInfoList &m_idList;
};

#endif // HEADGENASTCONSUMER_H
